<?php 
class HosturlAction extends BaseAction
{
	public function index()
	{

             $results= M('ht_url')->select();
			
			$this->results = $results;

			
			$this->display();
	}
	/**
	 * 更新（插入）视图
	 */
	public function update()
	{
	
		//更新
		if ( common_is_number($_GET['id']) )
		{
	
			$id = common_html_Arr($_GET['id']);
            $where = array('id'=>$id);
            $result = M('ht_url')->where($where)->find();
	        $this->result = $result;

		}

		$this->display();
			
	}


    /**
     *更新（插入）团队方法
     */
    public function doUpdate()
    {

        IS_POST || die('非法操作');
        //参数过滤
        $requestArr = $_POST;
        //P($requestArr);
        //die(P($_POST));
        //校验厨师名

        $requestArr['add_time'] = date("Y-m-d H:i:s");


        //实例化model
        $hosturlModel = new HosturlModel();
        //插入
        if ( common_is_number($requestArr['id']) == NULL )
        {
            //插入数据
            $result = $hosturlModel->insert($requestArr);

            if ( $result > 0 )
            {
                $response['status'] = 1;

                $response['info'] = '添加成功';
            }
            else
            {
                $response['status'] = 0;

                $response['info'] = '添加失败';
            }


        }
        //更新
        else
        {
            //P($requestArr);
            //更新数据

            $result = $hosturlModel->update($requestArr, $requestArr['id']);

            if ( $result !== false )
            {
                $response['status'] = 1;

                $response['info'] = '修改成功';
            }
            else
            {
                $response['status'] = 0;

                $response['info'] = '修改失败';
            }

        }

        die(json_encode($response));


    }



	/**
	 *删除控制
	 */
	public function del()
	{
			
		IS_AJAX || die('非法提交');
			
		$requset = common_html_Arr($_POST);
			
		//WeddingModel model
		$LeaveModel = new HosturlModel();
			
		$result = $LeaveModel->del($requset['check']);
			
		if ( $result > 0 )
		{
			$response['status'] = 1;
	
			$response['info'] = '删除成功';
		}
		else
		{
	
			$response['status'] = 0;
	
			$response['info'] = '删除失败';
	
		}
			
		die(json_encode($response));
	}
}


?>